package com.hongyuan.venue.ui.home.view_mode;

import androidx.annotation.NonNull;
import androidx.databinding.ObservableField;
import com.hongyuan.mvvmhabitx.binding.command.BindingCommand;
import com.hongyuan.venue.base.ItemViewModel;
import com.hongyuan.venue.data.Constants;
import com.hongyuan.venue.ui.home.beans.TopTimeBean;
import com.hongyuan.venue.utils.TimeUtil;

public class TimeTopItemViewModel extends ItemViewModel<ScheduledViewModel> {

    public ObservableField<TopTimeBean> entity = new ObservableField<>();

    public TimeTopItemViewModel(@NonNull ScheduledViewModel viewModel, TopTimeBean bean) {
        super(viewModel);
        entity.set(bean);
    }

    //条目的点击事件
    public BindingCommand itemClick = new BindingCommand(() -> {
        if(viewModel.itemViewModel != this){
            viewModel.itemViewModel.entity.get().setSelect(false);
            viewModel.itemViewModel.entity.notifyChange();

            viewModel.itemClick(this);

            viewModel.curPage = viewModel.FIRST_PAGE;

            viewModel.setParams("os_id",viewModel.userToken.getOs_id())
                    .setParams("date",entity.get().getNow_day())
                    .requestData(Constants.GYM_RESERVE_LIST);
        }
    });
}
